<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>a</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>scrf: <span id="sp" th:text="${csrf}"/></h1>
<h1><span th:text="${a}"/></h1>
<h2 id="h2">请求值</h2>
<button id='bt' type="button" value="post请求">post请求</button>

<script type="text/javascript">
    $('#bt').click(function () {
        $.ajax({
            type: "POST",
            headers: {
                "pac4jCsrfToken": $('#sp').text()
            },
            url: "/a4",
            success: function (data) {
                $('#h2').html(data)
            }
        });
    })
</script>
</body>
</html>